package com.songcha.library_database_sakura

import android.app.Application
import android.content.Context
import com.songcha.library_database_sakura.greendao.DaoMaster
import com.songcha.library_database_sakura.greendao.DaoSession
import com.songcha.library_database_sakura.helper.MyDaoOpenHelper

class LibraryDatabaseSakuraApplication {
    companion object{
        //var isDebug=true
        private lateinit var mContext:Application
        private lateinit var mSession: DaoSession

        @JvmStatic
        fun init(context: Application){
            mContext=context
            //LibraryDatabaseSakura.isDebug=isDebug

            val devOpenHelper =  MyDaoOpenHelper(mContext, "greendao.db")
            val db = devOpenHelper.writableDatabase
            val daoMaster =  DaoMaster(db)
            mSession = daoMaster.newSession()

        }

        @JvmStatic
        fun getContext():Context{
            return mContext
        }

        fun getDaoSession():DaoSession{
            return mSession
        }
    }
}